#ifndef MCURSORS_CONFIG_H
#define MCURSORS_CONFIG_H

#include <QtGui/QTextCharFormat>
#include <QtGui/QBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QFrame>

#include <KColorButton>
#include <KComboBox>
#include <KCModule>

class MCursorsConfig
: public KCModule
{
	Q_OBJECT

public:
	struct DefaultValues {
		QColor cursorColor;
		int underlineStyle;
		QColor underlineColor;

		DefaultValues()
		: cursorColor(0,0,0,40)
		, underlineStyle(1)
		, underlineColor(Qt::red)
		{}
	};

public:
	explicit MCursorsConfig(QWidget *parent = 0, const QVariantList &args = QVariantList());
	virtual ~MCursorsConfig();

	virtual void save();
	virtual void load();
	virtual void defaults();

	inline static QTextCharFormat::UnderlineStyle getUnderlineStyle(int index)
	{
		switch (index) {
			case 1: return QTextCharFormat::SingleUnderline;
			case 2: return QTextCharFormat::DashUnderline;
			case 3: return QTextCharFormat::DotLine;
			case 4: return QTextCharFormat::DashDotLine;
			case 5: return QTextCharFormat::DashDotDotLine;
			default: return QTextCharFormat::NoUnderline;
		}
	}

	inline static int getIndexUnderlineStyle(QTextCharFormat::UnderlineStyle style)
	{
		switch (style) {
			case QTextCharFormat::SingleUnderline: return 1;
			case QTextCharFormat::DashUnderline: return 2;
			case QTextCharFormat::DotLine: return 3;
			case QTextCharFormat::DashDotLine: return 4;
			case QTextCharFormat::DashDotDotLine: return 5;
			default: return 0;
		}
	}

private Q_SLOTS:
	void slotChanged();
	void underlineStyleindexChanged(int);

private:
	QVBoxLayout m_layout;

	QFrame m_underline_frame;

	QHBoxLayout m_underline_color_hlayout;
	QHBoxLayout m_underline_style_hlayout;
	QHBoxLayout m_bg_color_hlayout;

	KComboBox m_underline_style;
	KColorButton m_underline_color;
	QLabel m_underline_color_label;
	QLabel m_underline_style_label;
	QLabel m_bg_color_label;
	KColorButton m_cursor_color;
};

#endif // MCURSORS_CONFIG_H
